/** 查询生成表数据 */
import { Api } from "@vitejs/plugin-vue";

export function listTableApi(query: GenTableRecord): Promise<ApiRowsRecord<GenTableRecord[]>> {
  return request({
    url: '/tool/gen/list',
    method: 'get',
    params: query
  })
}

/** 查询db数据库列表 */
export function listDbTableApi(query: GenTableRecord): Promise<ApiRowsRecord<GenTableRecord[]>> {
  return request({
    url: '/tool/gen/db/list',
    method: 'get',
    params: query
  })
}

/** 查询表详细信息 */
export function getGenTableApi(tableId: number): Promise<ApiDataRecord<GenInfoRecord>> {
  return request({
    url: '/tool/gen/' + tableId,
    method: 'get'
  })
}

/** 修改代码生成信息 */
export function updateGenTableApi(data: GenTableRecord): Promise<ApiRecord> {
  return request({
    url: '/tool/gen',
    method: 'put',
    data: data
  })
}

/** 导入表 */
export function importTableApi(data: { tables: string }): Promise<ApiRecord> {
  return request({
    url: '/tool/gen/importTable',
    method: 'post',
    params: data
  })
}

/** 预览生成代码 */
export function previewTableApi(tableId: number): Promise<ApiRecord> {
  return request({
    url: '/tool/gen/preview/' + tableId,
    method: 'get'
  })
}

/** 删除表数据 */
export function delTableApi(tableId: number): Promise<ApiRecord> {
  return request({
    url: '/tool/gen/' + tableId,
    method: 'delete'
  })
}

/** 生成代码（自定义路径） */
export function genCodeApi(tableName: string): Promise<ApiRecord> {
  return request({
    url: '/tool/gen/genCode/' + tableName,
    method: 'get'
  })
}

/** 同步数据库 */
export function synchDbApi(tableName: string): Promise<ApiRecord> {
  return request({
    url: '/tool/gen/synchDb/' + tableName,
    method: 'get'
  })
}